package com.nuanshui.heatedloan.credit.pay.behavior;

import com.aipg.common.AipgReq;
import com.alibaba.fastjson.JSON;
import com.nuanshui.framework.behavior.BehaviorAttribute;
import com.nuanshui.heatedloan.credit.pay.AllinPayAccountMgr;
import com.nuanshui.heatedloan.credit.pay.PayContext;
import com.nuanshui.heatedloan.credit.pay.PayRequest;
import com.nuanshui.heatedloan.credit.pay.annotation.PayBehaviorAttribute;
import com.nuanshui.heatedloan.credit.pay.constant.PayBehaviorType;
import com.nuanshui.heatedloan.credit.pay.utils.AllinPayUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 选择通联账号
 */
@PayBehaviorAttribute(value= PayBehaviorType.SelectAccountBehavior,order=200)
public class SelectAccountBehavior extends PayBehavior {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private AllinPayAccountMgr allinPayAccountMgr;

    private AipgReq createReq(PayRequest request) {

        return allinPayAccountMgr.createReq(request);
    }

    @Override
    public void internalInvoke(PayRequest request) {

        AllinPayUtil.logOrderPay(logger, request, "通联支付账号准备开始");

        AipgReq req=createReq(request);

        PayContext.getContext().setAipgReq(req);

        AllinPayUtil.logOrderPay(logger, request, "准备通联支付账号准备结束:"+ JSON.toJSONString(req.getINFO()));
    }
}
